﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace GetSerier
{
    public class GetSerier
    {
        private string[] direc, winList;

        private string[] filTyper = { ".mkv", ".avi", ".ts", ".mp4" };

        public GetSerier(string[] path)
        {

            int tot = 0;

            foreach (string f in path)
            {
                string[] dir = Directory.GetDirectories(f);
                foreach (string g in dir)
                    tot++;
            }

            direc = new string[tot];
            foreach (string f in path)
            {
                string[] dir = Directory.GetDirectories(f);
                dir.CopyTo(direc, getLastNull(direc));
            }
            winList = direc;
        }

        public string[] getDir(){
            return direc;
        }
        public string getDirec(int index)
        {
            return direc[index];
        }
        public string getName(int index){
            return winList[index];
        }
        private int getLastNull(string[] temp){
            for (int i = 0; i < temp.Length; i++)
                if (temp[i] == null)
                    return i;
            return -1;
        }
        public string[] getSubDir(string sub){
            Console.WriteLine(sub);
            for (int i = 0; i < this.filTyper.Length; i++)
                if (sub.EndsWith(this.filTyper[i]))
                    return null;
            return Directory.GetDirectories(sub);
        }
        public void setWinList(string[] winList){
            this.winList = winList;
        }

        public string[] getEpisoder(string pwd){
            return Directory.GetFiles(pwd, "*.*");
        }
    }
}